package com.wangdao.wechatmall.controller.admin;

import com.wangdao.wechatmall.bean.vo.admin.BaseRespVo;
import com.wangdao.wechatmall.bean.vo.admin.DashBoardVO;
import com.wangdao.wechatmall.service.admin.GoodsService;
import com.wangdao.wechatmall.service.admin.OrderService;
import com.wangdao.wechatmall.service.admin.GoodsProductService;
import com.wangdao.wechatmall.service.admin.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页表盘展示
 *
 * @author ZhangXiao on 2021/7/6
 */
@RestController
public class DashBoardController {

    @Autowired
    UserService userService;

    @Autowired
    GoodsService goodsService;

    @Autowired
    OrderService orderService;

    @Autowired
    GoodsProductService goodsProductService;

    @RequestMapping("admin/dashboard")
    public BaseRespVo dashboard(){
        DashBoardVO dashBoardVO = new DashBoardVO();

        long goodsTotal = goodsService.getGoodsNumber();
        dashBoardVO.setGoodsTotal(goodsTotal);

        long orderTotal=orderService.getOrderNumber();
        dashBoardVO.setOrderTotal(orderTotal);

        long productTotal = goodsProductService.getProductNumber();
        dashBoardVO.setProductTotal(productTotal);

        long userTotal= userService.getUserNumber();
        dashBoardVO.setUserTotal(userTotal);




        return BaseRespVo.ok(dashBoardVO);
    }
}
